Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add way to make subsurfaces from surfaces #448

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

maxhbooth
Copy link
Contributor

I'd like to be able to pass an existing surface and make it a subsurface, instead of using the surface created in create_subsurface. Would that be possible with something like this? Thanks :)

@wash2
Copy link
Member

wash2 commented Apr 11, 2024

What exactly is the use case for this? If the passed surface already has a role, this will be a protocol error, and a surface cannot be its own parent anyway, or else you get a protocol error. https://wayland.app/protocols/wayland#wl_subcompositor:request:get_subsurface

@maxhbooth
Copy link
Contributor Author

What exactly is the use case for this?

For me, I have existing code that takes a surface and stores it until I determine if it is going to be a xdg-toplevel or xdg-popup. Once I've determined what role it is going to be I pass the surface xdg-shell::create_window or Popup::from_surface respectively. I'd like to like to use similar logic to also create subsurfaces.

If the passed surface already has a role, this will be a protocol error,

I know that my surfaces won't have a role yet. I'd be happy to add a check for that, but I don't think we have enough information here to know.

and a surface cannot be its own parent anyway, or else you get a protocol error. https://wayland.app/protocols/wayland#wl_subcompositor:request:get_subsurface

I feel like I could just as easily use create_subsurface to generate a protocol error if I'd like to, I'm not sure that it's different here.

@wash2
Copy link
Member

wash2 commented Apr 11, 2024

I know that my surfaces won't have a role yet. I'd be happy to add a check for that, but I don't think we have enough information here to know.

Ok, gotcha.

I think the function might need a better name because currently it's a bit hard to tell without checking the implementation if it is creating a subsurface that is a child of the passed surface, or if it is creating a subsurface from the passed surface. Maybe subsurface_from_surface?

It could possibly return an Option so that it doesn't have to unwrap on the parent surface.

@maxhbooth maxhbooth force-pushed the feature/create-subsurface branch from e3ab33e to d4cca5a Compare April 11, 2024 17:51
@maxhbooth
Copy link
Contributor Author

Thanks, I wasn't too sure what a good name for it would be. Done.

@maxhbooth maxhbooth force-pushed the feature/create-subsurface branch from d4cca5a to 1a146b0 Compare April 11, 2024 20:17
@maxhbooth maxhbooth force-pushed the feature/create-subsurface branch from 1a146b0 to 953b418 Compare April 12, 2024 14:44
@maxhbooth maxhbooth force-pushed the feature/create-subsurface branch from 953b418 to b37bdf8 Compare April 12, 2024 14:44
@maxhbooth
Copy link
Contributor Author

Sorry for the lint error

@wash2 wash2 merged commit 18070ad into Smithay:master Apr 12, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants